package org.freez4.spring.conversion;

import org.freez4.spring.ioc.overview.domain.User;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.beans.PropertyEditor;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Spring 自定义 {@link PropertyEditor} 示例
 *
 * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
 * @see PropertyEditor
 * @since
 */
public class SpringCustomizedPropertyEditorDemo {

    private static final Logger logger = Logger.getLogger(SpringCustomizedPropertyEditorDemo.class.getName());

    public static void main(String[] args) {
        // 创建并且启动 BeanFactory 容器，
        ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/META-INF/property-editors-context.xml");
        User user = applicationContext.getBean("user", User.class);
        logger.log(Level.INFO, user::toString);
        // 显示地关闭 Spring 应用上下文
        applicationContext.close();
    }

}